package com.wanxi.controller;

import com.wanxi.VO.NewsClassVO;
import com.wanxi.VO.UserVO;
import com.wanxi.dto.ResultDTO;
import com.wanxi.service.NewsClassService;
import com.wanxi.service.UserService;
import com.wanxi.service.impl.NewsClassServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by IntelliJ IDEA.
 * 新闻分类
 * @Author : 林子淳
 * @create 2023/3/10 15:58
 */
@RestController
public class NewsClassController {
    @Autowired
    private NewsClassService newsClassService;
    @PostMapping("/back/newsClass/add")
    @CrossOrigin
    protected ResultDTO add(NewsClassVO newsClassVO, HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ResultDTO resultDTO = newsClassService.add(newsClassVO);
        return resultDTO;
    }
    @PostMapping("/back/newsClass/delete")
    @CrossOrigin
    protected ResultDTO delete(NewsClassVO newsClassVO, HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ResultDTO resultDTO = newsClassService.delete(newsClassVO);
        return resultDTO;
    }
    @GetMapping("/back/newsClass/findAll")
    @CrossOrigin
    protected ResultDTO findAll(NewsClassVO newsClassVO, HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ResultDTO resultDTO = newsClassService.findAll(newsClassVO);
        return resultDTO;
    }
    @GetMapping("/back/newsClass/findById")
    @CrossOrigin
    protected ResultDTO findById(NewsClassVO newsClassVO, HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ResultDTO resultDTO = newsClassService.findById(newsClassVO);
        return resultDTO;
    }
    @PostMapping("/back/newsClass/update")
    @CrossOrigin
    protected ResultDTO update(NewsClassVO newsClassVO, HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ResultDTO resultDTO = newsClassService.update(newsClassVO);
        return resultDTO;
    }


}
